package com.tanhua.controller;
import com.tanhua.service.DashboardService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("dashboard")
public class DashboardController {

    @Autowired
    DashboardService dashboardService;

    @Value("${jwt.secret}")
    private String secret;
    @GetMapping("summary")
    public ResponseEntity<Object> dashboard(@RequestHeader("Authorization") String token){
        Map map = dashboardService.finddashboarddata();
        System.out.println("hellwo        3.33333333");
        System.out.println("改变一下");
        if (map!=null){
            return ResponseEntity.ok(map);
        }
        return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(null);
    }

    @GetMapping("users")
    public ResponseEntity<Object> users(@RequestParam Map<String, Object> map) {

    HashMap<String,List<Map<String,Integer>>> hashMap=      dashboardService.findaddactivekeep(map);


        if (map!=null){



            return ResponseEntity.ok(hashMap);
        }
        return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(null);
    }
    }